/*    */ package com.zimbra.cs.filter.jsieve;
/*    */ 
/*    */ import com.zimbra.common.filter.Sieve.Comparator;
/*    */ import com.zimbra.soap.mail.type.FilterTest.Importance;
/*    */ import java.util.Arrays;
/*    */ import java.util.List;
/*    */ import java.util.ListIterator;
/*    */ import org.apache.jsieve.Argument;
/*    */ import org.apache.jsieve.Arguments;
/*    */ import org.apache.jsieve.SieveContext;
/*    */ import org.apache.jsieve.StringListArgument;
/*    */ import org.apache.jsieve.exception.SieveException;
/*    */ import org.apache.jsieve.exception.SyntaxException;
/*    */ import org.apache.jsieve.mail.MailAdapter;
/*    */ import org.apache.jsieve.tests.Header;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public final class ImportanceTest
/*    */   extends Header
/*    */ {
/*    */   protected boolean executeBasic(MailAdapter mail, Arguments arguments, SieveContext context)
/*    */     throws SieveException
/*    */   {
/* 42 */     ListIterator<Argument> argumentsIter = arguments.getArgumentList().listIterator();
/*    */     FilterTest.Importance importance;
/* 44 */     if (argumentsIter.hasNext()) {
/* 45 */       Argument argument = (Argument)argumentsIter.next();
/* 46 */       FilterTest.Importance importance; if ((argument instanceof StringListArgument)) {
/* 47 */         importance = FilterTest.Importance.valueOf((String)((StringListArgument)argument).getList().get(0));
/*    */       } else {
/* 49 */         throw new SyntaxException("Expecting a string");
/*    */       }
/*    */     } else {
/* 52 */       throw new SyntaxException("Unexpected end of arguments");
/*    */     }
/*    */     
/*    */     FilterTest.Importance importance;
/* 56 */     List<String> headers = Arrays.asList(new String[] { "Importance" });
/* 57 */     List<String> values = null;
/* 58 */     switch (importance) {
/*    */     case high: 
/* 60 */       values = Arrays.asList(new String[] { "High" });
/* 61 */       break;
/*    */     case low: 
/* 63 */       values = Arrays.asList(new String[] { "Low" });
/* 64 */       break;
/*    */     case normal: 
/* 66 */       values = Arrays.asList(new String[] { "High", "Low" });
/*    */     }
/* 68 */     boolean result1 = match(mail, Sieve.Comparator.iasciicasemap.toString(), ":is", headers, values, context);
/*    */     
/*    */ 
/*    */ 
/* 72 */     headers = Arrays.asList(new String[] { "X-Priority" });
/* 73 */     values = null;
/* 74 */     switch (importance) {
/*    */     case high: 
/* 76 */       values = Arrays.asList(new String[] { "1" });
/* 77 */       break;
/*    */     case low: 
/* 79 */       values = Arrays.asList(new String[] { "5" });
/* 80 */       break;
/*    */     
/*    */     case normal: 
/* 83 */       values = Arrays.asList(new String[] { "1", "5" });
/*    */     }
/* 85 */     boolean result2 = match(mail, Sieve.Comparator.iasciicasemap.toString(), ":is", headers, values, context);
/*    */     
/*    */ 
/*    */ 
/* 89 */     return (!result1) && (!result2);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/filter/jsieve/ImportanceTest.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */